<?php
/***************************************************************************
 *   Copyright (C) 2007 by Andrea Blankenstijn, David Dieulivol            *
 *   darkan9el@gmail.com, daviddieulivol5@hotmail.com                      *
 *                                                                         *
 *   All rights reserved.                                                  *
 *   This work is released under the terms of the New BSD License.         *
 *   See LICENSE.BSD file for licensing details                            *
 ***************************************************************************/
/* * *
 * $Id: rss.php 49 2007-08-27 18:23:57Z DarkAn9el $
 * * */
require 'classes/ugallery/rssFeed.class.php';

RssFeed::sendMimeType();
$items = array();

switch(@$_GET['chan'])
{
	case 'photo':
		$photos = Photo::listPhotos($odb);
		foreach($photos as $key => $photo)
		{
			$url  = 'http://localhost/ugallery/viewPhoto='. $photo['idPhotos'];
			$date = RssFeed::makeRFC822Date(strtotime($photo['date']));

			$items[$key][0]  = $photo['name'];
			$items[$key][1]  = $url;
			$items[$key][2]  = $photo['description'];
			$items[$key][3]  = $photo['idAuthors'];
			$items[$key][11] = $date;
		}
	break;

	default:
		$galleries = Gallery::listGalleries($odb);
		foreach($galleries as $key => $gallery)
		{
			$url  = 'http://localhost/ugallery/viewGallery='. $gallery['idGalleries'];
			$date = RssFeed::makeRFC822Date(strtotime($gallery['creationDate']));

			$items[$key][0]  = $gallery['name'];
			$items[$key][1]  = $url; 
			$items[$key][2]  = $gallery['description'];
			$items[$key][11] = $date;
		}
	break;
}

$feed = new RssFeed('µGallery demo WebUI', 'http://localhost/ugallery/', 'Sample RSS Feed from µGallery', $items);
echo $feed->getRenderedXml(true);

echo '<!--memory usage : ', xdebug_memory_usage()/1024, "KB\n";
echo 'memory peak : ', xdebug_peak_memory_usage()/1024, "KB\n";
echo 'execution time : ', xdebug_time_index(), 's-->';
?>